package com.hmall.api;

import com.hmall.common.domain.PageDTO;
import com.hmall.common.domain.PageQuery;
import com.hmall.dto.ItemDTO;
import com.hmall.dto.OrderDetailDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

/**
 * @author pengrui
 * @date 2024/12/18
 */
@FeignClient("item-service")
public interface ItemClient {

    @ApiOperation("分页查询商品")
    @GetMapping("/items/page")
    PageDTO<ItemDTO> queryItemByPage(PageQuery query);

    @ApiOperation("根据id批量查询商品")
    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    @ApiOperation("根据id查询商品")
    @GetMapping("/items/{id}")
    ItemDTO queryItemById(@PathVariable("id") Long id);

    @ApiOperation("新增商品")
    @PostMapping("/items")
    void saveItem(@RequestBody ItemDTO item);

    @ApiOperation("更新商品状态")
    @PutMapping("/items/status/{id}/{status}")
    void updateItemStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status);

    @ApiOperation("更新商品")
    @PutMapping("/items")
    void updateItem(@RequestBody ItemDTO item);

    @ApiOperation("根据id删除商品")
    @DeleteMapping("/items/{id}")
    void deleteItemById(@PathVariable("id") Long id);

    @ApiOperation("批量扣减库存")
    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);
}
